using System;
using System.Collections.Generic;
using System.Text;
using ENTITIES;
using DAL;
using Utility;

namespace BUS
{
   public class MaDealBUS
    {
        public static void Insert(TBMaDeal md)
        {
            MaDealDAL mdDAL = new MaDealDAL();
            mdDAL.Insert(md);
        }
        public static void Update(TBMaDeal md)
        {
            MaDealDAL mdDAL = new MaDealDAL();
            mdDAL.Update(md);
        }
        public static void Delete(int iD)
        {
            MaDealDAL mdDAL = new MaDealDAL();
            mdDAL.Delete(iD);
        }
        public static tbMaDealCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            MaDealDAL mdDAL = new MaDealDAL();
            return mdDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbMaDealCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            MaDealDAL mdDAL = new MaDealDAL();
            return mdDAL.Get(cri.Criter, 0, 0, tbMaDealColumns.MaDeal.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static TBMaDeal GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbMaDealColumns.MaDeal.ToString(), Condition.EQUAL, iD);
            MaDealDAL mdDAL = new MaDealDAL();
            tbMaDealCollection madealcollection = mdDAL.Get(cri.Criter,
                  0, 0, tbMaDealColumns.MaDeal.ToString(), OrderDirection.ASC.ToString(), out total);
            if (madealcollection.Count > 0)
                return madealcollection[0];
            return null;
        }
        public static tbMaDealCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            MaDealDAL mdDAL = new MaDealDAL();
            return mdDAL.Get(cri.Criter, 1, number,
             tbMaDealColumns.MaDeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbMaDealCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            MaDealDAL mdDAL = new MaDealDAL();
            return mdDAL.Get(cri.Criter, 1, number,
               tbMaDealColumns.MaDeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    }

